﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EntitiesGenerator.Utils
{
    public class Sql
    {
        public static List<string> GetAllTable(string connStr)
        {
            string sql = "Select Name FROM SysObjects Where XType='U' order by Name;";
            using (SqlConnection conn = new SqlConnection(connStr))
            {
                conn.Open();
                SqlCommand cmd = conn.CreateCommand();
                cmd.CommandText = sql;
                SqlDataAdapter ad = new SqlDataAdapter(cmd);

                DataTable table = new DataTable();
                ad.Fill(table);

                return table.AsEnumerable().Select(r => r["Name"].ToString()).ToList();
            }
        }
    }
}
